using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Input.Touch;
namespace WindowsGame4
{
    public class Enemy : Pawn
    {
        public float shootingRange = 300, projectileSpeed = 100;
        public GameTimer shootingTime;
        public Enemy()
            : base()
        {
            shootingTime = new GameTimer(1);
            shootingTime.bMultiTrigger = false;
        }
        public override void AI()
        {
            base.AI();
            Vector2 dir = GameManager.player.pos - pos;
            if (!GameManager.player.bDead && dir.Length()<shootingRange
                &&shootingTime.IsTime(GameManager.dt))
                Shoot();
        }
        public virtual void Shoot()
        {
        }
        public override void OnDeath()
        {
            base.OnDeath();
            if (bExplodeOnDeath)
            {
                ExhaustEmitter emitter = new ExhaustEmitter();
                emitter.pos = pos;
                emitter.minAngle = 0;
                emitter.maxAngle = 360;
                emitter.nEmits = 30;
                emitter.SetEmissionRate(0);
                emitter.target = this;
                emitter.moveSpeed = -200;
                emitter.bOntimer = true;
                GameManager.explosion.Play();
                emitter.lifeTime = 1;
                GameManager.AddObject(emitter);
            }
        }
    }
    
}
